package org.flashbrighton.as3bots.logic
{
	import org.flashbrighton.as3bots.models.CollidableType;
	import org.flashbrighton.as3bots.events.BotEvent;

	public class JoesBotLogic implements IBotLogic
	{
		private var _engineVal:Number;
		private var _rotationVal:Number;
		
		private var _mood:String;

		
		public function JoesBotLogic()
		{
			_engineVal = 1;
			_rotationVal = 0;
			_mood = "good";
		}


		public function run():void
		{
			if (_mood == "bad")
			{
				_engineVal = -_engineVal;
				_rotationVal = 1;
				_mood = "good";
			}
			else if (_mood == "good")
			{
				_rotationVal = 0;
			}
		}
		
		
		public function notify(event:BotEvent):void
		{
			if (event.collisionPoint > 0.5)
			{
				_mood = "bad";
			}
			else
			{
				_mood = "good";
			}
			
			if (event.targetType == CollidableType.WALL)
			{
				_mood = "bad";
			}
		}
		
		
		public function get enginePercent():Number
		{
			return _engineVal;
		}
		
		
		public function get rotatorPercent():Number
		{
			return _rotationVal;
		}
		
	}
}